import os
import datetime
import time
from sys import setrecursionlimit
setrecursionlimit(10000)

def qsort(arr):
    if len(arr) < 2:
        return arr
    else:
        pivot = arr[0]
        smaller = []
        bigger = []
        for i in arr[1:]:
            if i < pivot:
                smaller.append(i)
            else:
                bigger.append(i)
        
        return qsort(smaller) + [pivot] + qsort(bigger)
    
def main():
    files = ["m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"]
    for file in files:
        with open(f"{file}") as f:
            nums = f.read().split("\n")
            start = time.time()
            qsort(nums)
            end = time.time() 
            print(f"{file.split('.')[0]} {round((end - start)*1000)} milleseconds")

if __name__ == "__main__":
    main()
